import _ from 'lodash';
import dynamic from 'next/dynamic';
import { useRouter } from 'next/router';
import Seo from '@/core/components/Seo';
import { getIdFromSlug, getNameFromSlug } from '@/core/utils/slug';
import Breadcrumb from '../../../lib/lob/components/Breadcrumb';
import { useEffect, useState } from 'react';
import odooApi from '@/core/api/odooApi';
import { div } from 'lodash-contrib';

const BasicLayout = dynamic(() => import('@/core/components/layouts/BasicLayout'));
const ProductSearch = dynamic(() => import('@/lib/product/components/ProductSearch'));
const CategorySection = dynamic(() => import('@/lib/product/components/CategorySection'));

export default function CategoryDetail() {
  const router = useRouter();
  const { slug = '', page = 1 } = router.query;
  const [dataLob, setDataLob] = useState([]);
  const [finalQuery, setFinalQuery] = useState({});
  const [dataCategoriesProduct, setDataCategoriesProduct] = useState([])
  const [data, setData] = useState([])
  const dataIdCategories = []
  
  const categoryName = getNameFromSlug(slug);
  const lobId = getIdFromSlug(slug);
  const q = router?.query.q || null;

  return (
    <BasicLayout>
      <Seo
        title={`Beli ${categoryName} di Indoteknik`}
        description={`Jual ${categoryName} Kirim Jakarta Surabaya Semarang Makassar Manado Denpasar Balikpapan Medan Palembang Lampung Bali Bandung Makassar Manado.`}
        additionalMetaTags={[
          {
            property: 'keywords',
            content: `Jual ${categoryName}, harga ${categoryName}, ${categoryName} murah, toko ${categoryName}, ${categoryName} jakarta, ${categoryName} surabaya`,
          },
        ]}
      />

      <Breadcrumb categoryId={getIdFromSlug(slug)} />

      {!_.isEmpty(router.query) && (
        <ProductSearch query={router.query} categories={getIdFromSlug(slug)} prefixUrl={`/shop/lob/${slug}`} />
      )}
    </BasicLayout>
  );
}
